package com.example.myapp;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

public class MyGVAdapter extends BaseAdapter {

    private Context context;
    private List<String> levels;

    public MyGVAdapter(Context context, List<String> levels) {
        this.context = context;
        this.levels = levels;
    }

    public int getCount() {
        return levels.size();
    }

    @Override
    public String getItem(int i) {
        return levels.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if(view == null)
            view = LayoutInflater.from(context).inflate(R.layout.gv_item,viewGroup,false);
        TextView tvLevel = view.findViewById(R.id.tv_level);
        tvLevel.setText(getItem(i));
        return view;
    }
}
